<!DOCTYPE html>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script type="text/javascript" src="/socket.io/socket.io.js"></script>
	<script type="text/javascript">
		var socket = io.connect();

		socket.on('login', function(names){
			var str = '<br />';
			names.forEach(function(name){
				str += 'user ' + name + ' has logged in <br />';
			});
			document.getElementById('result').innerHTML = str;
		});

		function add(){
			socket.emit('login', document.getElementById('nickname').value);
		}
 
	</script>
</head>
<body>
	name:
	<input type="text" id="nickname">
	<input type="button" onclick="add()" value="login">
	<output id="result" />
</body>
</html>